import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '/main',
      name: 'main',
      children: [
        {
          path: '/index',
          name: 'index',
          component: resolve => require(['@/components/main/index'], resolve)
        },
        {
          path: '/homeindex',
          name: 'homeindex',
          component: resolve => require(['@/components/main/homeindex'], resolve)
        },
        {
          path: '/topic/:id',
          name: 'topic',
          component: resolve => require(['@/components/main/topic'], resolve)
        }
      ],
      component: resolve => require(['@/components/main'], resolve)
    },
    {
      path: '/render',
      name: 'render',
      children: [
        {
          path: '/square',
          name: 'square',
          component: resolve => require(['@/components/square'], resolve)
        },
        {
          path: '/homepage/:uid',
          name: 'homepage',
          component: resolve => require(['@/components/homepage'], resolve)
        },
        {
          path: '/hometopic/:id',
          name: 'hometopic',
          component: resolve => require(['@/components/hometopic'], resolve)
        },
        {
          path: '/user',
          name: 'user',
          meta: {
            needlogin: true
          },
          children: [
            {
              path: 'userinfo',
              name: 'userinfo',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/userinfo'], resolve)
            },
            {
              path: 'usertopic',
              name: 'usertopic',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/usertopic'], resolve)
            },
            {
              path: 'changepassword',
              name: 'changepassword',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/changepassword'], resolve)
            },
            {
              path: 'userarticle',
              name: 'userarticle',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/userarticle'], resolve)
            },
            {
              path: 'setting',
              name: 'setting',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/setting'], resolve)
            },
            {
              path: 'addtopic',
              name: 'addtopic',
              meta: {
                needlogin: true
              },
              component: resolve => require(['@/components/user/addtopic'], resolve)
            }
          ],
          component: resolve => require(['@/components/user'], resolve)
        },
        {
          path: '/userlogin',
          name: 'userlogin',
          component: resolve => require(['@/components/user/userlogin'], resolve)
        },
        {
          path: '/userregister',
          name: 'userregister',
          component: resolve => require(['@/components/user/userregister'], resolve)
        }
      ],
      component: resolve => require(['@/components/render'], resolve)
    },
    {
      path: '/browser',
      name: 'browser',
      component: resolve => require(['@/components/browser'], resolve)
    },
    {
      path: '/favorite',
      name: 'favorite',
      component: resolve => require(['@/components/favorite'], resolve)
    },
    {
      path: '/login',
      name: 'login',
      component: resolve => require(['@/components/login'], resolve)
    },
    {
      path: '/register',
      name: 'register',
      component: resolve => require(['@/components/register'], resolve)
    }
  ]
})
